﻿using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using NetMQ;
using NetMQ.Sockets; 

namespace Lawn.AppServer
{
    public static class MqServcieExtensions
    {

        public static IServiceCollection AddMqService(this IServiceCollection servcies)
        {

            servcies.AddOptions<OptionsRemoteServer>();
            servcies.AddOptions<OptionsPort>();
            servcies.AddTransient<IServerMq, ServerMq>();
            servcies.AddTransient<ISubHandler, SubHandler>();
            servcies.AddTransient<IPubHandler, PubHandler>();
            servcies.AddTransient<ITopicManager, DefaultTopicManager>();
            return servcies;
        }

        // public static IServiceCollection AddRemoteServerOptions(this IServiceCollection servcies)
        // {
        //     
        //     servcies.AddOptions<OptionsRemoteServer>().Configure(x=>>)
        //     
        //     return servcies;
        // }
        public static IServiceCollection AddDefaultSerializeProvider(this IServiceCollection servcies)
        {

            
            servcies.Replace(ServiceDescriptor.Transient<ISerializeProvider, DefaultSerializeProvider>());
             
            return servcies;
        }
        public static IServiceCollection AddProtobuff(this IServiceCollection servcies)
        {

            
            servcies.Replace(ServiceDescriptor.Transient<ISerializeProvider, ProtobufSerializeProvider>());
           
            return servcies;
        }
    }
}